import React from 'react'
// ===================================================================== Temp
import FormModal from '#cpt/temp/FormModal'
// ===================================================================== Declare
const { $fn, $Lazy } = window
// ===================================================================== Lazy
const $cache = $Lazy.file(()=>import('#private/cache-api'))
// ===================================================================== 修改登录密码
class Index extends React.Component{
	state = {
		formData : [
			{ label: '字典名称',		name: 'item_name', 	full:true, required: true },
			{ label: '描述',		name: 'remark', 	full:true, type:'textarea' },
		]
	}
	
	open = (label, name, code) => {
		this.setState({ label, name, code })
		this.modal.open({ formRef: this.formRef })
		this.submit = { dis_code: code }
	}
	
	render(){
		const { label, name, code } = this.state
		return FormModal.call(this,{ title: `${label} - 新增字典`, labelWidth:'s7', width:550, api:'dis-item/codeAuto',
			onRefresh:()=>{
				const _this = this.props.top
				$cache.then( async f => {
					const { formData } = _this.state
					// 检测方法
					$fn.setRow( formData, name, await f.getDicCache({ code, refresh:true }))
					//
					_this.setState({ formData })
				})
			}
		})
	}
}

export default Index